# Contributor: Ed Robinson <ed@reevoo.com>
# Maintainer: Ed Robinson <ed@reevoo.com>
pkgname=fontforge
pkgver=20200314
pkgrel=1
pkgdesc="FontForge is a free (libre) font editor for Windows, Mac OS X and GNU+Linux."
url="https://fontforge.org"
arch="all !s390x !x86 !mips !mips64" # test139_ff hangs on x86
license="GPL-3.0-or-later"
makedepends="
	cmake
	pango-dev
	giflib-dev
	tiff-dev
	libxml2-dev
	libspiro-dev
	python3-dev
	potrace
	woff2-dev
	gtk+3.0-dev
	libuninameslist-dev
	readline-dev
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-python3:_py3
	"
source="https://github.com/fontforge/fontforge/releases/download/$pkgver/fontforge-$pkgver.tar.xz
	fix-select.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build . \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DENABLE_GUI=ON \
		-DENABLE_X11=OFF \
		-DENABLE_PYTHON_SCRIPTING=ON \
		-DENABLE_PYTHON_EXTENSION=ON \
		-DENABLE_LIBSPIRO=ON \
		-DENABLE_LIBUNINAMESLIST=ON \
		-DENABLE_LIBGIF=ON \
		-DENABLE_LIBJPEG=ON \
		-DENABLE_LIBPNG=ON \
		-DENABLE_LIBREADLINE=ON \
		-DENABLE_LIBTIFF=ON \
		-DENABLE_WOFF2=ON \
		-DENABLE_DOCS=OFF \
		$CMAKE_CROSSOPTS .
	make -C build
}

check() {
	make -C build check
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

_py3() {
	pkgdesc="python3 bindings for $pkgname"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python3* "$subpkgdir"/usr/lib

	mkdir -p "$subpkgdir"/usr/share/fontforge/python
	mv "$pkgdir"/usr/share/fontforge/python/excepthook.py "$subpkgdir"/usr/share/fontforge/python
}

sha512sums="09f5dc93f87ca63668d72d108690604489d6b3cec7eedff1c07ad6d1ce5eae442ab60e79e71ae8b99e9808f3551011788025a86ffc3a9738518d99761d849975  fontforge-20200314.tar.xz
8cb3fb00fa537eab2d4b194916343a0e2aab85c2415a1944c0d0e648d62a7748d5d4465fb99cb92385b749e73abfcaa429f4c9d2bb4c2edea8febeb227add93a  fix-select.patch"
